<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/WEB-INF/faces/template.xhtml">
        <ui:define name="title">
            <h:outputText value="New Shipping Manifesto"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <p:growl sticky="true"/>
            </h:panelGroup>
            <p:panel header="New Shipping Manifesto" style="border: none;">
                <h:form>
                    <h:panelGrid id="entryPanel" columns="3">
                        <h:outputLabel value="Truck No" for="truck" />
                        <h:selectOneMenu id="truck" value="#{shippingBean.selected.truck}" requiredMessage="Required" required="true">
                            <f:selectItems value="#{truckBean.trucks}"/>
                        </h:selectOneMenu>
                        <p:message for="truck" />

                        <h:outputLabel value="Driver Name" for="driverName" />
                        <h:selectOneMenu id="driverName" value="#{shippingBean.selected.driver}" requiredMessage="Required" required="true">
                             <f:selectItems value="#{driverBean.drivers}"/>
                        </h:selectOneMenu>
                         <p:message for="driverName" />


                        <h:outputLabel value="From " for="shippingFrom" />
                        <h:inputText id="shippingFrom" value="#{shippingBean.selected.shippingFrom}" requiredMessage="Required" required="true"/>
                        <p:message for="shippingFrom" />
                        
                        <h:outputLabel value="To" for="shippingTo" />
                        <h:inputText id="shippingTo" value="#{shippingBean.selected.shippingTo}" requiredMessage="* Required" required="true"/>
                        <p:message for="shippingTo" />

                        <h:outputLabel value="Type Invoice Number" for="invoiceNumber" />
                        <h:inputText id="invoiceNumber" value="#{shippingBean.invoiceNumber}" requiredMessage="* Required" required="false"/>
                        <p:commandButton value="Add" action="#{shippingBean.addInvoice}" update="entryPanel" ajax="false"/>
                        <p:message for="invoiceNumber" />
                    </h:panelGrid>
                    <p:dataTable value="#{shippingBean.selected.allShippingItems}" var="item" rowIndexVar="index" >
                        <p:column>
                            <f:facet name="header">
                                SN
                            </f:facet>
                            <h:outputText value="#{index +1}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                Bilti #
                            </f:facet>
                            <h:outputText value="#{item.invoice.id}"/>
                        </p:column>
                         <p:column>
                            <f:facet name="header">
                                Quantity
                            </f:facet>
                             <h:outputText value="#{item.packageCount}"/>
                        </p:column>
                         <p:column>
                            <f:facet name="header">
                                Weight
                            </f:facet>
                             <h:outputText value="#{item.actualWeight}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                Description
                            </f:facet>
                            <h:outputText value="#{item.itemDiscription}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                Item Ref#
                            </f:facet>
                             <h:outputText value="#{item.referenceNumber}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                Invoice Date
                            </f:facet>
                            <h:outputText value="#{item.invoice.invoiceDate}"/>
                        </p:column>
                         <p:column>
                            <f:facet name="header">
                                Consignor
                            </f:facet>
                             <h:outputText value="#{item.invoice.consignor.companyName}"/>
                        </p:column>
                         <p:column>
                            <f:facet name="header">
                                PAN#
                            </f:facet>
                             <h:outputText value="#{item.invoice.consignor.panNumber}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                Consignee
                            </f:facet>
                            <h:outputText value="#{item.invoice.consignee.companyName}"/>
                        </p:column>
                         <p:column>
                            <f:facet name="header">
                                PAN#
                            </f:facet>
                             <h:outputText value="#{item.invoice.consignee.panNumber}"/>
                        </p:column>
                    </p:dataTable>
                    <br/>
                    <p:commandButton action="#{shippingBean.create}" value="Save" update="entryPanel"/>

                    <p:commandButton action="pretty:prepareManifesto" value="Cancel" immediate="true"/>

                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>

</html>
